/*
二分查找
http://10.134.1.2/nkuoj/#/problem/267356
 */
import java.util.*;
//import java.io.*;
//
//public class Main {
//    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//    static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
//
//    static long binarySearch(long[] arr, long toFind) {
//        long l = 0, r = arr.length;
//        while (l < r) {
//            long mid = (l + r) / 2;
//            if (arr[(int)mid] == toFind) {
//                return mid;
//            } else if (arr[(int)mid] < toFind) {
//                l = mid + 1;
//            } else {
//                r = mid;
//            }
//        }
//        return -1;
//    }
//
//    public static void main(String[] args) throws IOException {
//        String[] s = br.readLine().trim().split("\\s+");
//        int size = s.length;
//        long[] arr = new long[size];
//        for (int i = 0; i < size; i++) {
//            arr[i] = Long.parseLong(s[i]);
//        }
//        long toFind = Long.parseLong(br.readLine().trim());
//        long idx = binarySearch(arr, toFind);
//        if (idx >= 0 && arr[(int)idx] == toFind)
//            pw.println(idx);
//        else
//            pw.println(-1);
//        pw.close();
//    }
//}

/*
找到数组中第k小的数
http://10.134.1.2/nkuoj/#/problem/368541
 */
//import java.util.*;
//import java.io.*;
//
//public class Main {
//    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//    static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
//    static int n;
//    static void quickSortForKth(long[] arr,int l,int r,int k){
//        if(l>=r)return;
//        int i = l-1,j = r+1;
//        long x = arr[(l+r)/2];
//        while(i<j){
//            do i++;while(arr[i]<x);
//            do j--;while(arr[j]>x);
//            if(i<j){
//                long temp = arr[i];
//                arr[i] = arr[j];
//                arr[j] = temp;
//            }
//        }
//        int len = j - l + 1;
//        if(k <= len){
//            quickSortForKth(arr,l,j,k);
//        }
//        else{
//            quickSortForKth(arr,j+1,r,k-len);
//        }
//    }
//    public static void main(String[] args) throws IOException {
//        String[] line = br.readLine().trim().split("\\s+");
//        n = line.length;
//        long[] arr = new long[n];
//        for (int i = 0; i < n; i++) {
//            arr[i] = Long.parseLong(line[i]);
//        }
//        int k = Integer.parseInt(br.readLine().trim());
//        quickSortForKth(arr,0,n-1,k);
//        pw.println(arr[k-1]);
//        pw.close();
//    }
//}


/*
20
666666 666666 666666 66666 66666 66666 6666 6666 666 666 666 66 66 66 66 66 66 6 6 6
 */
import java.util.*;
import java.io.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    static int n;
    static ArrayList<Integer> arr = new ArrayList<>();
    static int[] a = new int[6];
    public static void main(String[] args) throws IOException {
        int n = Integer.parseInt(br.readLine().trim());
        String[] s1 = br.readLine().trim().split("\\s+");
        int res = 0;
        for (int i = 0; i < n; i++) {
            int cnt = 0;
            for (char ch : s1[i].toCharArray()) {
                if (ch == '6')
                    cnt++;
            }
            if (cnt >= 6)
                res++;
            else if (cnt > 0)
                a[cnt]++;
        }
//        for (int i = 0; i < 6; i++) {
//            pw.print(a[i] + " ");
//        }
//        pw.println();
        while(a[5]>0&&a[1]>0){
            a[5]--;a[1]--;
            res++;
        }
        while(a[5]>0&&a[2]>0){
            a[5]--;a[2]--;
            res++;
        }
        while(a[5]>0&&a[3]>0){
            a[5]--;a[3]--;
            res++;
        }
        while(a[5]>0&&a[4]>0){
            a[5]--;a[4]--;
            res++;
        }
        while(a[5]>=2){
            a[5]-=2;
            res++;
        }
        while(a[4]>0&&a[1]>=2){
            a[4]--;
            a[1]-=2;
            res++;
        }
        while(a[4]>0&&a[2]>0){
            a[4]--;
            a[2]--;
            res++;
        }
        while(a[4]>0&&a[3]>0){
            a[4]--;
            a[3]--;
            res++;
        }
        while(a[4]>=2){
            a[4]-=2;
            res++;
        }
        while(a[3]>=2){
            //3
            a[3]-=2;
            res++;
        }
        while(a[3]>0&&a[2]>0&&a[1]>0){
            //1
            a[3]--;
            a[2]--;
            a[1]--;
            res++;
        }
        while(a[3]>0&&a[2]>=2){
            //2
            a[3]--;
            a[2]-=2;
            res++;
        }

        while(a[2]>=3){
            //4
            a[2]-=3;
            res++;
        }
        pw.println(res);
        pw.flush();
    }
}

